using System;
using System.Collections;
using System.Data;
using BEGDC.CC.Entity;

namespace BEGDC.CC.BL.UserManagement
{
    /// <summary>
    /// Summary description for IUser.
    /// </summary>
    public interface IUser
    {
        /// <summary>
        /// Get user list
        /// </summary>
        /// <param name="pageIndex">list page index</param>
        /// <param name="total">out total user count</param>
        /// <param name="pageSize">number of user list in each page</param>
        /// <param name="bg">BusinessGroup</param>
        /// <param name="bu">BusinessUnit</param>
        /// <param name="adname">user's adname</param>
        /// <param name="englishname">user's english name</param>
        /// <param name="status">user status</param>
        /// <returns>DataTable</returns>
        DataTable GetUserList(int pageIndex, out int total, int pageSize, string bg, string bu, string adname, string englishname, int status);

        /// <summary>
        /// Get all user list
        /// </summary>
        /// <returns>user object list</returns>
        IList GetUserList();

        /// <summary>
        /// Get all user
        /// </summary>
        /// <returns>user datatable</returns>
        DataTable GetUserDataTable(string filter);

        /// <summary>
        /// Get all user
        /// </summary>
        /// <returns>user datatable</returns>
        DataTable GetUserDataTable();

        /// <summary>
        /// Get all role list
        /// </summary>
        /// <returns>IList</returns>
        IList GetRoleList();

        DataTable GetCODPPCheckPersons(bool domestic);

        /// <summary>
        /// Gets the related CODPP check person NO of a department.
        /// </summary>
        /// <param name="departmentId">The department id.</param
        /// <param name="domestic">Domestic EZVisit request</param>
        /// <returns>The CODPP Check person NO.</returns>
        string GetCODPPCheckPersonNo(int departmentId, bool domestic);

        DataTable GetRoleDataTable();

        DataTable GetDelegationRoleDataTable();

        /// <summary>
        /// Get user by userid
        /// </summary>
        /// <param name="UserID">userid</param>
        /// <returns>user object</returns>
        Employee GetUserByID(string UserID);

        /// <summary>
        /// Get role by role name
        /// </summary>
        /// <param name="name">role name</param>
        /// <returns>role object</returns>
        //		CODMRole GetRole(string name);
        /// <summary>
        /// Get user by adname
        /// </summary>
        /// <param name="ADName">adname</param>
        /// <returns>employee object</returns>
        Employee GetUser(string ADName);

        /// <summary>
        /// Get engineer by type
        /// </summary>
        /// <param name="engineerType">engineer type</param>
        /// <returns>DataTable</returns>
        DataTable GetEngineerByType(string engineerType, string sql);

        /// <summary>
        /// Search user by adname
        /// </summary>
        /// <param name="aDName">adname</param>
        /// <returns>user list</returns>
        IList SearchUser(string aDName);

        /// <summary>
        /// check whether user is in role
        /// </summary>
        /// <param name="adname">adname</param>
        /// <param name="roleid">roleid</param>
        /// <returns>true/false</returns>
        bool IsInRole(string adname, int roleid);

        //=====================Added by Joe 2007/6/10===================
        /// <summary>
        ///
        /// </summary>
        /// <param name="nameEN"></param>
        /// <param name="roleName"></param>
        /// <returns></returns>
        bool IsInRole(string nameEN, string roleName);

        /// <summary>
        ///
        /// </summary>
        /// <param name="stepName"></param>
        /// <param name="roleName"></param>
        /// <param name="nameEN"></param>
        /// <param name="appId"></param>
        /// <returns></returns>
        bool IsInRole(string stepName, string roleName, string nameEN, int appId);

        /// <summary>
        ///
        /// </summary>
        /// <param name="adname"></param>
        /// <returns></returns>
        bool IsBusinessAdmin(string adname);

        //===========================End==============================

        /// <summary>
        /// Get role list of a user
        /// </summary>
        /// <param name="adname">adname</param>
        /// <returns>role list</returns>
        IList GetRolesByUser(string adname);

        /// <summary>
        /// Get user by english name
        /// </summary>
        /// <param name="englishName">english name</param>
        /// <returns>employee object</returns>
        Employee GetUserByEnglishName(string englishName);

        /// <summary>
        /// Get user by workflowid and role
        /// </summary>
        /// <param name="NBPMFlow">workflowid</param>
        /// <param name="rolename">role name</param>
        /// <returns>user list</returns>
        IList GetUserByWorkflowRole(long NBPMFlow, string rolename);

        /// <summary>
        /// Get user by workflowid and rolw for TS
        /// </summary>
        /// <param name="NBPMFlow"></param>
        /// <param name="rolename"></param>
        /// <returns></returns>
        IList GetUserByWorkflowRoleForTS(long NBPMFlow, string rolename);

        /// <summary>
        /// Get Users by HQL search
        /// </summary>
        /// <param name="hqlString">HQL search string</param>
        /// <returns>user list</returns>
        IList GetUserByHQL(string hqlString);

        /// <summary>
        /// check whether a user is in role of a project
        /// </summary>
        /// <param name="adname">adname</param>
        /// <param name="roleid">roleid</param>
        /// <param name="NBPMFlow">workflowid</param>
        /// <returns>true/false</returns>
        bool IsInRole(string adname, int roleid, long NBPMFlow);

        /// <summary>
        /// check whether a user is in role of a project
        /// </summary>
        /// <param name="adname">adname</param>
        /// <param name="roleName">role name</param>
        /// <param name="NBPMFlow">workflowid</param>
        /// <returns>true/false</returns>
        bool IsInRole(string adname, string roleName, long NBPMFlow);

        /// <summary>
        /// check whether a user is in role of a project
        /// </summary>
        /// <param name="adname">adname</param>
        /// <param name="roleName">role name</param>
        /// <param name="projectID">projectid</param>
        /// <returns></returns>
        bool IsInRole(string adname, string roleName, int projectID);

        //Added by Joe Feng 1/29/2007 ->begin
        /// <summary>
        ///
        /// </summary>
        /// <param name="adname"></param>
        /// <param name="roleName"></param>
        /// <param name="flowId"></param>
        /// <returns></returns>
        bool IsInTSRole(string adname, string roleName, long flowId);

        //->end
        /// <summary>
        /// Add user into role
        /// </summary>
        /// <param name="roleID">roleid</param>
        /// <param name="userID">userid</param>
        /// <returns>true/false</returns>
        bool AddUser(int roleID, int userID);

        /// <summary>
        /// Remove user from role
        /// </summary>
        /// <param name="roleID">roleid</param>
        /// <param name="userID">userid</param>
        /// <returns>true/false</returns>
        bool RemoveUser(int roleID, int userID);

        /// <summary>
        /// check whether a user is in role
        /// </summary>
        /// <param name="roleID">roleid</param>
        /// <param name="userID">userid</param>
        /// <returns>true/false</returns>
        bool IsContained(int roleID, int userID);

        /// <summary>
        /// Get user list by role
        /// </summary>
        /// <param name="roleName">role name</param>
        /// <returns>DataTable</returns>
        DataTable GetUserByRole(string roleName);

        /// <summary>
        /// Get email list by role
        /// </summary>
        /// <param name="roleName">role name</param>
        /// <returns>DataTable</returns>
        DataTable GetEmailByRole(string roleName);

        /// <summary>
        /// Get user list by role
        /// </summary>
        /// <param name="roleName">role name</param>
        /// <returns>CODMRole object</returns>
        //		CODMRole GetUserByRoleName(string roleName);
        /// <summary>
        /// GetUserByRole
        /// </summary>
        /// <param name="role">roleid</param>
        /// <returns>IList</returns>
        IList GetUserByRole(int role);

        /// <summary>
        /// Get users by their role
        /// </summary>
        /// <param name="roleId"></param>
        /// <param name="isEnabled">true, false</param>
        /// <returns>an list of users</returns>
        IList GetUserByRole(int roleId, bool isEnabled);

        /// <summary>
        /// get user by role and BG
        /// </summary>
        /// <param name="roleID">roleid</param>
        /// <param name="BG">BusinessGroup</param>
        /// <returns>IList</returns>
        IList GetUserByRoleBG(int roleID, string BG);

        /// <summary>
        /// get user by role and BU
        /// </summary>
        /// <param name="roleID">roleid</param>
        /// <param name="BU">BusinessUnit</param>
        /// <returns>IList</returns>
        IList GetUserByRoleBU(int roleID, string BU);

        /// <summary>
        /// get user by role name and BG
        /// </summary>
        /// <param name="roleName">role name</param>
        /// <param name="BG">BusinessGroup</param>
        /// <returns>DataTable</returns>
        DataTable GetUserByRoleBG(string roleName, string BG);

        /// <summary>
        /// get user by role name and BU
        /// </summary>
        /// <param name="roleName">role name</param>
        /// <param name="BU">Business Group</param>
        /// <returns>DataTable</returns>
        DataTable GetUserByRoleBU(string roleName, string BU);

        //update Jovi.Chen 2007/3/2
        DataTable GetUserByRoleBU(string roleName, string[] BU);

        /// <summary>
        /// get user defined column list
        /// </summary>
        /// <param name="employeeid">employeeid</param>
        /// <returns>DataTable</returns>
        DataTable GetUserColumn(int employeeid);

        /// <summary>
        /// get column list which user not defined
        /// </summary>
        /// <param name="employeeid">employeeid</param>
        /// <returns>DataTable</returns>
        DataTable GetUserNoColumn(int employeeid);

        /// <summary>
        /// Save user profile
        /// </summary>
        /// <param name="userprofile">userprofile object</param>
        /// <returns>true/false</returns>
        //		bool SaveUserProfile(UserProfile userprofile);
        /// <summary>
        /// Get all business group list
        /// </summary>
        /// <returns>DataTable</returns>
        DataTable GetBusinessGroupList();

        /// <summary>
        /// Get business unit by business group
        /// </summary>
        /// <param name="bg">Business Group</param>
        /// <returns>DataTable</returns>
        DataTable GetBusinessUnitList(string bg);

        /// <summary>
        /// Get Role lis by employee id
        /// </summary>
        /// <param name="EmployeeID">EmployeeID</param>
        /// <returns>role list</returns>
        IList GetRolesByUserID(string EmployeeID);

        /// <summary>
        /// Get Role by id
        /// </summary>
        /// <param name="id">user role id</param>
        /// <returns>role </returns>
        BEGDC.CC.Entity.Role GetRoleByID(int id);

        BEGDC.CC.Entity.Role GetRole(string name);

        /// <summary>
        /// Get User Role by id
        /// </summary>
        /// <param name="id">user role id</param>
        /// <returns>user role </returns>
        BEGDC.CC.Entity.UserRole GetUserRoleByID(int id);

        BEGDC.CC.Entity.UserRole GetUserRoleByUserAndRole(string employeeNo, string roleName);

        BEGDC.CC.Entity.UserRole GetUserRoleByUserAndRoleID(string employeeNo, string roleID);

        /// <summary>
        /// Get User Role by id
        /// </summary>
        /// <param name="id">user  id</param>
        /// <returns>user role </returns>
        IList GetDelegationUserRoleListByUserID(string userid, string delegationuserid);

        /// <summary>
        /// Save user role
        /// </summary>
        /// <param name="userrole"></param>
        /// <returns></returns>
        bool SaveUserRole(UserRole userRole);

        bool DetachAllDelegationFromUser(string employeeId);

        bool DetachOneDelegationFromUser(string employeeId, string roleID);

        /// <summary>
        /// Get role list not defined by user
        /// </summary>
        /// <param name="EmployeeID">employeeid</param>
        /// <returns>role list</returns>
        IList GetNoRolesByUser(string EmployeeID);

        /// <summary>
        /// Save user defined role list
        /// </summary>
        /// <param name="user">user id</param>
        /// <param name="source">not defined role list</param>
        /// <param name="target">defined role list</param>
        /// <param name="adname">adname</param>
        /// <returns>true/false</returns>
        bool SaveUserRole(string user, string source, string target);

        bool DetachRoleFromUser(string user);

        /// <summary>
        /// Get users not in role
        /// </summary>
        /// <param name="roleID">roleid</param>
        /// <returns>user list</returns>
        IList GetNoUserByRole(int roleID);

        /// <summary>
        /// Save user role relationship by roleid
        /// </summary>
        /// <param name="roleid">roleid</param>
        /// <param name="source">user list not in role</param>
        /// <param name="target">user list in role</param>
        /// <returns>true/false</returns>
        bool SaveUserRoleByRole(int roleid, string source, string target);

        /// <summary>
        /// Get role by id
        /// </summary>
        /// <param name="id">roleid</param>
        /// <returns>role object</returns>
        //		CODMRole GetRole(int id);

        /// <summary>
        /// Get all employees who set the specified employee as backup
        /// </summary>
        /// <param name="EmployeeID">Employee ID</param>
        /// <returns>employees list</returns>
        IList GetBackups(string employeeId);

        /// <summary>
        /// Set user status
        /// </summary>
        /// <param name="ids">user id list</param>
        /// <param name="isEnabled">enable status</param>
        /// <returns>true/false</returns>
        bool SetUserStatus(string ids, bool isEnabled);

        /// <summary>
        /// Get userprofile by id
        /// </summary>
        /// <param name="id">userid</param>
        /// <returns>UserProfile object</returns>
        //		UserProfile GetUserProfile(int id);
        /// <summary>
        /// Get email of project owner
        /// </summary>
        /// <param name="projectId">projectid</param>
        /// <returns>DataTable</returns>
        DataTable GetProjectOwnerEmail(int projectId);

        /// <summary>
        /// Get matrix by family
        /// </summary>
        /// <param name="familyId">familyid</param>
        /// <param name="roleName">role name</param>
        /// <returns>DataTable</returns>
        DataTable GetMatrixByFamily(int familyId, string roleName);

        /// <summary>
        /// Get department by role
        /// </summary>
        /// <param name="roleName">role name</param>
        /// <returns>DataTable</returns>
        DataTable GetDepartmentByRole(string roleName);

        /// <summary>
        /// Get department by type
        /// </summary>
        /// <param name="typeName">department type name</param>
        /// <returns>DataTable</returns>
        DataTable GetDepartmentByType(string typeName);

        /// <summary>
        /// Get Cat/PSO
        /// </summary>
        /// <returns></returns>
        DataTable GetCATPSOUser();

        DataTable GetCostCenterHeadUser();

        DataTable GetFNCUser();

        DataTable GetCostCenterHead();

        DataTable GetFNCDeptByUserRoleID(int userroleid);

        DataTable GetCostCenterHeadByUserRoleID(int userroleid);

        bool RemoveFNCDept(int userroleID, int departmentID);

        bool SaveFNCDept(int userroleID, int departmentID);

        bool RemoveCostCenterHead(int userroleID, int costcenterID);

        bool SaveCostCenterHead(int userroleID, int costcenterID);

        bool SaveCostCenterHeads(string cil, int costcenterHeadId, string costcenterIDs);

        string GetCostCenterByConstCenterHead(string employeeNo);

        string GetCostCenterByDepartment(string departmentNo);

        /// <summary>
        /// Save user role CAT by id
        /// </summary>
        /// <param name="roleid">roleid</param>
        /// <param name="catbranchid">CAT/Branch</param>
        /// <returns>true/false</returns>
        bool SaveUserRole_CAT(int roleid, int catbranchid);

        /// <summary>
        /// Save user role Cost Center by id
        /// </summary>
        /// <param name="roleid"></param>
        /// <param name="costcenterid"></param>
        /// <returns></returns>
        bool SaveUserRole_CostCenterHead(int roleid, int costcenterid);

        /// <summary>
        ///
        /// </summary>
        /// <param name="isCAT">true, CAT; false, PSO</param>
        /// <param name="dept"></param>
        /// <returns></returns>
        DataTable GetDirector(string dept);

        /// <summary>
        ///
        /// </summary>
        /// <param name="employee"></param>
        /// <returns></returns>
        bool IsCODStaff(string employee, string type);

        /// <summary>
        ///
        /// </summary>
        /// <param name="employee"></param>
        /// <param name="type"></param>
        /// <returns></returns>
        bool IsCODManager(string employee, string type);

        /// <summary>
        ///
        /// </summary>
        /// <param name="employee"></param>
        /// <returns></returns>
        bool IsLastOperator(string employee, int appId);

        /// <summary>
        /// 		///
        /// </summary>
        /// <param name="nameEN"></param>
        /// <param name="apID"></param>
        /// <returns></returns>
        string GetAPAccessAuthority(string nameEN, int apID);

        /// <summary>
        /// Save agreement
        /// </summary>
        /// <param name="employee"></param>
        /// <returns>true/false</returns>
        bool SaveAgreement(string employee);

        /// <summary>
        /// Save agreement
        /// </summary>
        /// <param name="employee"></param>
        /// <returns>true/false</returns>
        bool SaveAgreement(Agreement agreement);

        /// <summary>
        /// Save agreement
        /// </summary>
        /// <param name="employee"></param>
        /// <returns>true/false</returns>
        bool SaveEmployee(Employee employee);

        /// <summary>
        /// Transfer task
        /// </summary>
        /// <param name="employeeno"></param>
        /// <param name="transferto">transfer to(employee no)</param>
        /// <param name="appIDs"></param>
        /// <returns></returns>
        bool TransferTask(string employeeno, string transferto, string appIDs);

        /// <summary>
        /// initialize user role . add role "CVApplicant", "CRApplicant", "EVApplicant"
        /// </summary>
        /// <param name="employeeno"></param>
        /// <returns></returns>
        bool InitUserRole(string employeeno);

        bool InitUserRole(BEGDC.CC.BL.Workflow.CCIdentity employee);

        /// <summary>
        ///
        /// </summary>
        /// <param name="employee"></param>
        /// <param name="appId"></param>
        /// <returns></returns>
        bool IsApplicant(string employee, int appId);

        bool IsApprover(string employeeNo);

        DataTable GetCostCenterByUserId(string cil);

        DataTable GetDelegateUserByCurrentUser(string employeeNo);




        #region Permission

        SystemFunction GetFunctionByID(int id);

        DataTable GetFunctions();

        DataTable GetPermissionByRole(string roles);

        bool SavePermission(int functionid, string source, string target);

        IList GetRolesByPermission(int functionid);

        #endregion
    }
}
